# Collaborative Editing

The collaborative editing feature allows multiple users to edit the same document simultaneously. Document content is transmitted to the server in real time and can be stored directly on the server, eliminating the need for clients to initiate manual save requests.

Collaborative editing requires server-side support from [Umo Editor Server](../server), although you may also configure your own provider.

## Effect Screenshot

![Collaborative Editing](https://s2.umodoc.com/demos/collaboration-en.png)

## Features and Advantages

- Support for private deployment, allowing you to deploy privately or customize service providers to ensure data security and controllability;
- Real-time offline and online collaboration, supporting synchronization of document changes even when users reconnect after being offline;
- Real-time communication with the server through WebSocket to achieve instant document content synchronization;
- Communication with other applications through Webhook to synchronize document content, comments, and other information;
- Support for document comment collaboration, where users can comment on documents with real-time synchronization to the server;
- Umo Editor Server supports 100,000+ users editing simultaneously, enabling efficient multi-user collaboration with cluster deployment support.

## Default Configuration

```js
const defaultOptions = {
  // Collaborative editing configuration
  document: {
    id: '', // In multi-user collaboration scenarios, document ID is required to uniquely identify a document
  },
  collaboration: {
    enabled: false,
    provider: {},
  },
}
```

## Unsupported Configurations

When online collaboration is enabled, the following configurations are not supported:

```js
const defaultOptions = {
  document: {
    content:'',
    autoSave: {
      // ...
    },
  },
  onSave(){
    // ...
  }
}
```

This is because in collaborative scenarios, document content is transmitted to the server in real time and can be stored directly on the server, removing the need for the client to trigger save requests.

## Configuration Description

### collaboration

Configuration related to collaborative editing. For implementation principles and mechanisms, refer to: https://tiptap.dev/docs/hocuspocus.

- `collaboration.enabled`

**Description**: Whether to enable online collaboration.

**Type**: Boolean

- `collaboration.provider`

**Description**: Configuration of the collaboration service provider. Umo Editor Next provides a default Node.js server-side solution based on [Express](https://expressjs.com/?hl=en), which includes a built-in Hocuspocus Server (see: [Umo Editor Server](../server)). This option supports all configuration options of the Hocuspocus Server.

**Type**: Object

**Configuration**: Options follow the Hocuspocus Server configuration, see: https://tiptap.dev/docs/hocuspocus/provider/configuration.

## Method List

For examples of method usage, see: [Method List](../editor/methods).

### getCollaboration

**Description**: Retrieves information related to online collaboration.

**Parameters**: None

**Return Value**: Object or `undefined`. The returned object contains the following information:
- `connect`: Boolean — whether the connection to the provider was successful.
- `user`: Array — the list of users currently collaborating on the document.
- `provider`: Object — the service provider information. With this information, you can listen to relevant events to implement custom features. See: https://tiptap.dev/docs/hocuspocus/provider/events#option-2-binding.
